Solving 10385 - Duathlon (Ternary search)
[and.git] / 11428 - Cubes / b.2.cpp
bloba584ca6d02bf37871311022e72fca7cc77d27701
1 #include<iostream>
2 #include<math.h>
3 using namespace std;
5 int cubo(int x){
6 int i=1;
7 while(i*i*i <= x){
8 ++i;
10 --i;
11 // cout << i << endl;
12 if (i*i*i == x){
13 return i;
14 }else{
15 return INT_MAX;
19 int main(){
20 int n;
21 while(cin>>n &&n){
22 int y = 1;
23 bool encontre=false;
24 while (true){
25 int r = cubo(n + (y*y*y));
26 // cout << "r es: " << r << " y es: " << y << endl;
27 if (r != INT_MAX){
28 cout << r << " " << y << endl;
29 encontre = true;
30 break;
32 ++y;
33 if ((y+1)*(y+1)*(y+1) - y*y*y > n) break;
35 if (!encontre){
36 cout << "No solution\n";
37 continue;